<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<h1><fmt:message key="login.title"/></h1>

<div class="section">
    <table>
        <tr>
            <th><fmt:message key="login.username"/></th>
            <th><fmt:message key="login.password"/></th>
            <th><fmt:message key="login.role"/></th>
        </tr>
        <tr>
            <td>1</td>
            <td>1</td>
            <td>ROLE_USER, ROLE_ADMIN</td>
        </tr>
        <%--        <tr><td>david</td><td>newyork</td><td>ROLE_USER,ROLE_ADMIN</td></tr>
        <tr><td>alex</td><td>newjersey</td><td>ROLE_USER</td></tr>
        <tr><td>tim</td><td>illinois</td><td>ROLE_USER</td></tr>--%>
    </table>
</div>
<div class="section">
    <c:if test="${not empty param.login_error}">
        <div class="errors">
            <fmt:message key="login.msg.failure"/><br/><br/>
            <fmt:message
                    key="login.failure.reason"/>: <%= ((AuthenticationException) session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage() %>
        </div>
    </c:if>
</div>

<div class="section">
    <form name="loginForm" id="loginForm" action="login" method="post">
        <table>
            <tr>
                <th>
                    <div class="label"><label for="j_username"><fmt:message key="login.username"/>:</label></div>
                </th>
                <td>
                    <div class="output">
                        <input type="text" name="j_username" id="j_username"
                               <c:if test="${not empty param.login_error}">value="<%= session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY) %>"
                        </c:if> />
                    </div>
                </td>
            </tr>
            <tr>
                <th>
                    <div class="label"><label for="j_password"><fmt:message key="login.password"/>:</label></div>
                </th>
                <td>
                    <div class="output">
                        <input type="password" name="j_password" id="j_password"/>
                    </div>
                </td>
            </tr>
            <tr>
                <th>
                    <div class="label"><label for="remember_me"><fmt:message key="login.rememberMe"/>:</label></div>
                </th>
                <td>
                    <div class="output">
                        <input type="checkbox" name="_spring_security_remember_me" id="remember_me"/>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2"><input name="submit" id="submit" type="submit"
                                       value="<fmt:message key="button.login"/>"/></td>
            </tr>
        </table>
    </form>
</div>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>